import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pornhub_app/model/axis_cover.dart';

import '../../assets/styles.dart';
import '../../model/episode/episode_models.dart';
import '../image_view.dart';
import '../../utils/extension.dart';

class EpisodeBaseCell extends StatelessWidget {
  final double width;
  final double imageHeight;
  final EpisodeVideoModel episodeVideo;
  final VoidCallback? onTap;
  final CoverImgAxis coverAxis;

  EpisodeBaseCell.smallVertical(this.episodeVideo, {super.key, this.onTap})
      : width = 119.w,
        imageHeight = 162.w,
        coverAxis = CoverImgAxis.vertical;

  Widget _buildCover() {
    return ImageView(
      src: episodeVideo.coverByAxis(coverAxis),
      height: imageHeight,
      width: width,
      borderRadius: Styles.borderRadius.m,
      axis: coverAxis,
    );
  }

  Widget _buildTitle() {
    return Text(episodeVideo.title,
        maxLines: 1, overflow: TextOverflow.ellipsis);
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: width,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          _buildCover(),
          SizedBox(height: 8.w),
          _buildTitle(),
        ],
      ),
    ).onTap(onTap);
  }
}
